#ifndef __ESP8266_H__
#define __ESP8266_H__

#include "sys.h"
#include "delay.h"
#include "stdio.h"
#include "string.h"
#include "FreeRTOS.h"
#include "task.h"
#include "uart1.h"
#include "string.h"
#include "MQTT.h"

#define ESP8266_UART USART2

#define ESP8266_RST_GPIO_Port GPIOA
#define ESP8266_RST_Pin GPIO_PIN_4
#define ESP8266_RST_GPIO_CLK_ENABLE()    __HAL_RCC_GPIOA_CLK_ENABLE()

#define ESP8266_EOK 0
#define ESP8266_ERROR 1

#define ESP8266_TX_PIN GPIO_PIN_2
#define ESP8266_TX_GPIO_PORT GPIOA
#define ESP8266_TX_GPIO_CLK_ENABLE()    __HAL_RCC_GPIOA_CLK_ENABLE()

#define ESP8266_RX_PIN GPIO_PIN_3
#define ESP8266_RX_GPIO_PORT GPIOA
#define ESP8266_RX_GPIO_CLK_ENABLE()    __HAL_RCC_GPIOA_CLK_ENABLE()

void ESP8266_Init(void);
void esp8266_test(void);
void esp8266_mode(uint8_t mode);
uint8_t esp8266_set_single_path_mode(void);
uint8_t ESP8266_SendCmd(char *cmd, char *rev, uint32_t timeout_ms);
void esp8266_reset_software(void);
void ESP8266_AP_Mode(char *ssid, char *password);
uint8_t ESP8266_Read(uint8_t *data);
void ESP8266_Send_data(char *data, uint16_t len);
void esp8266_copy_rxdata(char *data);
uint8_t ESP8266_Wait_receive(uint32_t timeout_ms);
uint8_t esp8266_connect_tcp_server(char *server_ip, char *server_port);
uint8_t esp8266_enter_unvarnished(void);
uint8_t esp8266_enter_unvarnished(void);
uint8_t ESP8266_get_flag(void);

#endif
